<template>
    <div class="newsinfo-container">
        <h1 class="title">{{newsinfo.title}}</h1>
        <p class="subtitle">
            <span>发布时间: {{ newsinfo.add_time | dataFormat}}</span>
            <span>点击次数：{{ newsinfo.click }}次</span>
        </p>
        <div class="content" v-html="newsinfo.content"></div>

        <comment-box :id="this.id"></comment-box>
    </div>
</template>

<script>
    import { Toast } from 'mint-ui'
    import comment from '@/components/comment/comment'

    export default {
        name: "newsInfo",
        data(){
            return {
                id: this.$route.params.id,
                newsinfo: {}
            }
        },
        components: {
            'comment-box':comment
        },
        created() {
            this.getNewsInfo();
        },
        methods:{
            getNewsInfo(){
                this.$axios.get('/api/getnew/'+ this.id).then(result=>{
                    if(result.data.status === 0){
                        this.newsinfo = result.data.message[0];
                    }else {
                        Toast('请求失败');
                    }
                })
            }
        }
    }
</script>

<style lang="scss" scoped>
    .newsinfo-container {
        background: #fff;
        padding: 0 15px;
        .title {
            font: 600 16px/32px "";
            color: #ff5053;
            text-align: center;
        }
        .subtitle {
            display: flex;
            justify-content: space-between;
            font: 12px/24px "";
            color: #007aff;
            border-bottom: 1px solid #ddd;
        }
        .content {
            font-size: 12px;
            line-height: 18px;
            color: #555;
        }
    }
</style>
